﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using COFE.Core;
using NUnit.Framework;

namespace COFE.Web
{
    /// <summary>
    /// Represents a UserProfile in IUserProfileManager2, allow construction.
    /// </summary>
    public class User
    {
        #region Constructor

        public User(IUserProfile2 userProfile)
        {
            _userName = userProfile.UserName;
            foreach (var pp in userProfile.Volumes.PrimaryVolumes)
                _volumes.Add(pp.ListerKey);
            foreach (var vol in userProfile.Volumes.SecondaryVolumes)
                _volumes.Add(vol.ListerKey);
        }

        #endregion

        #region Methods

        public void CreateUser()
        {
            Assert.IsNotNull(UserName);
            Assert.IsNotNull(Password);
            COFEWSShared.UserProfileManager.CreateUser(UserName, Password);
        }

        public void DeleteUser()
        {
            Assert.IsNotNull(UserName);
            COFEWSShared.UserProfileManager.DeleteUser(UserName);
        }
       

        #endregion

        #region Data

        string _userName, _password;        
        List<string> _volumes = new List<string>();

        #endregion

        #region Public Properties

        public string UserName { get { return _userName; } set { _userName = value; } }
        public string Password { get { return _password; } set { _password = value; } }
        public List<string> Volumes { get { return _volumes; } }

        #endregion
    }
}
